﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Presentation.Shell.Interfaces;
using Presentation.Module.Scheduling.Interfaces;
using Presentation.Module.Scheduling.Interfaces.Views;
using Microsoft.Practices.Prism.Regions;

namespace Presentation.Module.Scheduling
{
    /// <summary>
    /// Interaction logic for ScheduleLandingPage.xaml
    /// </summary>
    

    public partial class ScheduleLandingPage : UserControl, IModuleLandingPage
    {

        public ScheduleLandingPage(IRegionManager regionManager, IScheduleStudyView scheduleStudyView)
        {
            InitializeComponent();


            this.RegionManager = regionManager;
            this.ScheduleStudyView = scheduleStudyView;

            this.RegionManager.Regions["MainRegion"].Add(this.ScheduleStudyView);

            this.ScheduleStudyView.ViewExit += ExitScheduleStudyView;
        }

        private IRegionManager RegionManager { get; set; }
        private IScheduleStudyView ScheduleStudyView { get; set; }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
  
            RegionManager.Regions["MainRegion"].Activate(ScheduleStudyView);
        }

        /// <summary>
        /// Occurs when [view exit].
        /// </summary>
        public event Shell.Interfaces.ViewExit ViewExit;

        /// <summary>
        /// Cancels the specified sender.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void Cancel(object sender, System.Windows.RoutedEventArgs e)
        {
            if (this.ViewExit != null)
            {
                this.ViewExit.Invoke();
            }
        }

        public object ParentView { get; set; }

        /// <summary>
        /// Exits the studies view.
        /// </summary>
        private void ExitScheduleStudyView()
        {
            this.RegionManager.Regions["MainRegion"].Activate(this);
        }
    }
}
